In the last video we included the sharp rise so to our portfolio analysis and to our graph here is a
couple of the portfolios.
And in this video we will identify the best portfolio with the highest chop ratio the so-called maximum
sharp ratio portfolio.
And this should be somewhere here in this region.
So we have still important.
The portfolio summary data frame with our 100 thousand portfolios and the annualized the return risk
and the ratio.
And we again can also call the scribe method here and we can see that the best portfolio has a sharp
ratio of one point eighteen and in the next step we want to find exactly this portfolio.
But first of all we have also here the weights matrix with the weights of the 100000 portfolios and
we want to find the max sharp racial portfolio and we can do this by selecting the shop column of our
portfolio summary data frame and then we use the idea X Max method and by doing so append us actually
returns as the index labor of uh the portfolio with the highest chop ratio and we can also look at inside
the idea X Max method.
So let's have a look here.
So the idea X Max method returns the roll label of the maximum value in this case in the shop column
and then we actually save for the row label and the variable maximum Sharpe Ratio portfolio.
So let's do this here and let's have a look.
So we have 100000 portfolios and.
The portfolio with the indexed label seventy six thousand eight hundred seventy nine has the highest
chop ratio of one point eighty in and now we can also select the row with the maximum Sharpe ratio in
our portfolio summary data frame and of course we can do this with the ILO operator and we pass here
the ROE label.
Let's have a look here.
So here the very best portfolio gives us a an annualized return of 25 percent.
We have a risk in terms of standard deviation of 19 percent.
And of course we uh the shop ratio the max job ratio of one point eighteen and that's actually the portfolio
with the number seventy six thousand eight hundred seventy nine.
And we can also get the weights of this portfolio by passing the ROE label of the best portfolio which
is also the index positions so we have a uh Range Index starting from zero.
So we pass here the index position to the weights matrix and then we get the weights of uh this best
portfolio and we save the weights and the variable maximum sharp racial portfolio weights so here we
have uh the six weights and to have a better overview we can also create a panda series with the stock
ticker as the index.
And are our weights.
So let's do this and let's have a look.
So here in our best portfolio we have for the Amazon stock a rate of 27 percent for the Boeing column
of 39 percent.
Then we have only one point seven percent.
This may then almost 0 percent IBM 5 percent Coca-Cola and the 25 percent Microsoft in our portfolio.
And this is actually the best portfolio of our 100000 random portfolios but it's actually not the absolutely
best portfolio.
So we can also optimize for the very best portfolio by using some advanced optimization algorithms.
But this is clearly beyond the scope of this course.
And I have done this in the background and I could solve for the weights of the very best portfolio.
So we say for the weights and the variable optimal weights and let's have a look here.
So by using some optimization algorithms we get here the very best portfolio.
And here we can see that we have zero weight for Disney IBM and Coca-Cola and the 25 percent for Amazon
35 percent for Boeing and 39 percent for Microsoft.
So this is our very best portfolio are the weights of our very best portfolio.
And then we can also create the evaded average daily returns.
For this portfolio and we create a new column for our returns data frame and we will see the top method
and pass the optimal weights.
So let's do this and let's have a look.
So here we have our six constituents.
And on the right hand side that daily returns of the maximum Sharpe Ratio portfolio MP and we can also
create these summary data frame by passing the returns that are frame to our user defined function annualized
the risk and return.
So let's do this.
And we also add the column shop with the top ratio which is the portfolio return minus the return of
the risk free rate divided by the risk of the portfolio.
So let's do this and let's have a look.
So here we have in the very last row of our maximum sharp racial portfolio with some return of 25 percent
a risk of 20 percent and the maximum Sharpe ratio of one point nineteen six.
And finally of course we can also visualize our results here.
So we create a scatter blood again with all of our 100000 portfolios.
And on the x axis we have the risk and on the y axis the return and the color is determined by the sharp
ratio.
And we also create a point or a star with the the maximum Sharpe Ratio portfolio.
So it's a black star here.
And uh let's have a look.
So here we have our 100000 portfolios.
And here is the Black Star we can see the maximum sharp ratio portfolio that we derive to with our optimization
algorithm.
So that's the very best portfolio that we could have created five years ago.
So for the period of the last five years and actually you might ask yourself why exactly this portfolio
is here the maximum Sharpe Ratio portfolio so it could also be another portfolio here on the efficient
frontier.
So for example this one and exactly this question I have a hand and answer in the next video.
So I hope to see you there by.